package rename;


import org.junit.Test;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;

public class Rname {

    @Test
    public void renameTest() throws IOException {
        String filePath = "C:\\WorkGit\\AcceptSendDemo\\src";
        RenameDir(filePath);
    }

    private void RenameDir(String filePath) throws IOException {
        File current=new File(filePath);
        File[] files=current.listFiles();
        for(File item:files){
            if(item.isDirectory()){
                RenameDir(item.getAbsolutePath());
            }
            else{
                if(item.getName().endsWith(".class")){
                    String absPath=item.getAbsolutePath();
                    absPath=absPath.replace(".class",".java");
                    File newFile=new File(absPath);
                    newFile.createNewFile();
                    System.out.println("create file :"+absPath);
                }
            }
        }
    }

}
